// const BASE_URL = 'http://124.220.177.66:8083';
// const BASE_URL = 'http://172.16.112.98';
//ECT
// const BASE_URL = 'http://172.16.112.98:80';
// const BASE_URL = 'http://172.16.112.173:8010';

//lm地址
// const BASE_URL = 'http://172.16.112.98:8010';
// const BASE_URL = 'http://172.16.112.123:8090';
// const BASE_URL = 'http://172.16.112.180:8003';

// const BASE_URL = 'http://172.16.112.48:8050';//财务
// const BASE_URL = 'http://172.16.112.173:8010';
// const BASE_URL = 'http://172.16.112.219:8061';
const BASE_URL = 'http://172.16.112.98:80';//报表管理

// const BASE_URL = 'http://172.16.112.123:8090'
// const BASE_URL = 'http://172.16.112.98:8090'
// const BASE_URL = 'http://172.16.112.219:8061';
// const BASE_URL = '';//登录
// const BASE_URL = 'http://172.16.112.48:8050';//财务
// const BASE_URL = 'http://172.16.112.173:8010';
// const BASE_URL = 'http://172.16.112.219:8061';//首页
// const BASE_URL = 'http://172.16.112.98:8010';//报表管理

const json2url = (json) => {
  let arr = [];
  for (let name in json) {
    arr.push(name + '=' + json[name]);
  }
  return arr.join('&')
}
const http = ({ url, method = 'get', params = {}, data = {} }) => {
  let start_time = new Date().getTime();
  if (!url) return;

  // const token = sessionStorage.getItem('token') || '';
  let option = {
    method,
    headers: {
      'Content-Type': 'application/json',
      'token':'eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI0MmNmNzg1MmE0ZmQ0MTI3OTRiM2MzNTJlZmFhYTMyZiIsInN1YiI6IjYiLCJpc3MiOiJzZyIsImlhdCI6MTY1Njk5MDI4OCwiZXhwIjoyNDM0NTkwMjg4fQ.41zoVYXIHTJnQX_8t4tUb0_Yeh-SDw5Czh-X40CeO-4'
    }
  }
  if (method === 'post') {
    option.body = JSON.stringify(data);
  }
  return fetch(BASE_URL + url + '?' + json2url(params), option).then(response => response.json())
}

export default http;


